<?php

/**
 * Description of Klasifikasi
 *
 * @author DENY PRASETIA TW
 * http://denyprasetiatw.blogspot.com/
 * Created Feb 10, 2012 - 8:36:13 PM
 */
class Klasifikasi extends CI_Model {
    
    private $dataBidang  = array('IDBIDANG', 'NAMABIDANG');
    private $tabelBidang = "T_BIDANG";
    
    private $dataPokok   = array('IDPOKOK', 'NAMAPOKOK');
    private $tabelPokok  = "T_POKOK";
    
    private $dataSub     = array('KODESUB', 'JENISSUB');
    private $tabelSub    = "T_SUB";

    public function __construct() {
        parent::__construct();
    }
        
    public function tampilkanBidang() {
        $this->db->trans_begin();
        $this->db->select($this->dataBidang);
            $this->db->from($this->tabelBidang);
            $this->query = $this->db->get();
        $this->db->trans_complete();
        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
        }else {
            $this->db->trans_commit();
            return $this->query->result();
        }
    }
    
    public function tampilkanPokok($input) {
        $this->db->trans_begin();
        $this->db->select($this->dataPokok);
            $this->db->from($this->tabelPokok);
            $this->db->where('IDBIDANG', $input['idBidang']);
            $this->query = $this->db->get();
        $this->db->trans_complete();
        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
        }else {
            $this->db->trans_commit();
            return $this->query->result();
//            foreach($this->query->result() as $row){
//                echo $row->IDPOKOK;
//                echo $row->NAMAPOKOK;
//                echo "</br>";
//            }
        }
    }
    
    public function tampilkanSub($input) {
        $this->db->trans_begin();
        $this->db->select($this->dataSub);
            $this->db->from($this->tabelSub);
            $this->db->where('IDPOKOK', $input['idPokok']);
            $this->query = $this->db->get();
        $this->db->trans_complete();
        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
        }else {
            $this->db->trans_commit();
            return $this->query->result();
//            foreach($this->query->result() as $row){
//                echo $row->KODESUB;
//                echo $row->JENISSUB;
//                echo "</br>";
//            }
        }
    }
    
}

?>
